'use strict';
module.exports = app => {
  const { STRING, INTEGER, TEXT } = app.Sequelize;
    const Model = app.model.define(
      'conditionValue',
      {
          id: {type: INTEGER, primaryKey: true, autoIncrement: true},
          condition_id: INTEGER(11),
          goods_id: INTEGER(11),
          field_value: TEXT(),
      },
      {
          tableName: 'condition_value',
          timestamps: true, // 启用时间戳(createdAt, updatedAt)
          updatedAt: 'updated_time', // 不想要 updatedAt
          createdAt: 'create_time', // 想要  createdAt 但是希望名称叫做 created_at
      }
  );
    Model.associate = function() {
        app.model.ConditionValue.belongsTo(app.model.Condition, {foreignKey: 'condition_id', targetKey: 'id'});
        // 一个条件值归属于一个商品
        app.model.ConditionValue.belongsTo(app.model.Goods, {foreignKey: 'goods_id', targetKey: 'id'});
    }
    return Model;
};
